<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        padding:0px;
        margin:0px;
        list-style: none;
    }
    ul{
        overflow: hidden;
    }
    ul li{
        width:100px;
        height: 30px;
        float:left;
        margin-right: 20px;
    }
    ul li:nth-of-type(1)
    {
        background: red;
    }
    section div{
                 width: 500px;
                height: 200px;
                text-align: center;
                line-height: 200px;
                display: none;
    }
    section div:nth-of-type(1){
        display:block;
    }
</style>
<body>
    <ul>
        <li>我的</li>
        <li>最好</li>
        <li>热门</li>
        <li>购物</li>
        <li>游戏</li>
    </ul>
    <section>
        <div>我的内容</div>
        <div>最好内容</div>
        <div>热门内容</div>
        <div>购物内容</div>
        <div>游戏内容</div>
    </section>
    <script>
        var tags=document.getElementsByTagName('li');
        var boxs=document.getElementsByTagName('div');
        for(i=0;i<tags.length;i++){
            tags[i].index=i;
            tags[i].onclick=function(){
                for(j=0;j<tags.length;j++){
                    tags[j].style.background="none";
                    boxs[j].style.display="none";
                }
                this.style.background='red';
                var n=this.index;
                boxs[n].style.display='block'
            }
        }
        
    </script>
</body>
</html>